home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-07 | 1.6 KB | 64 lines | [TEXT/ALFA] |
- #================================================================================
- # 'greplist' and 'grepfset' are used for batch searching from the "find" dialog.
- # Hence, you really shouldn't mess with them unless you know what you are doing.
- #================================================================================
- proc greplist {args} {
- set num [expr [llength $args] - 2]
- set exp [lindex $args $num]
- set arglist [lindex $args [expr $num + 1]]
-
- set owin 0
- set cid [scancontext create]
-
- set cmd [lrange $args 0 [expr $num - 1]]
- eval scanmatch $cmd {$cid $exp {
- if (!$owin) {
- set owin 1
- new
- set w [lindex [winNames -f] 0]
- }
- insertText -w $w "File \"[file tail $f]\"; Line $matchInfo(linenum): $matchInfo(line)\r"}
- }
-
- foreach f $arglist {
- set fid [open $f]
- scanfile $cid $fid
- close $fid
- }
- scancontext delete $cid
- }
-
- proc grepfset {args} {
- global fileSets
-
- set num [expr [llength $args] - 2]
- set exp [lindex $args $num]
- set fset [lindex $args [expr $num + 1]]
- eval greplist [lrange $args 0 [expr $num-1]] {$exp $fileSets($fset)}
- }
-
- proc grep {exp args} {
- set files {}
- foreach arg $args {
- if {![catch {glob -t TEXT $arg} lst]} {
- append files " " $lst
- }
- if {![catch {glob -t ttro $arg} lst]} {
- append files " " $lst
- }
- }
- if {$files==""} {return $lst}
- set cid [scancontext create]
- scanmatch $cid $exp {append lines "File \"[file tail $f]\"; Line $matchInfo(linenum): $matchInfo(line)\r"}
- set lines ""
-
- foreach f $files {
- set fid [open $f]
- scanfile $cid $fid
- close $fid
- }
- scancontext delete $cid
- return $lines
- }
-
-